package com.Cfeng.XiaohuanChat.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author Cfeng
 * @date 2022/8/12
 * 登录用户上传的笔记实体类，使用JSP时，向前台传送数据不需要传送笔记的标题和描述，作者，直接@JsonIgnore
 * 需要进行网络传输，所以进行序列化
 */

@Accessors(chain = true)
@Data
@Entity
public class UserNote implements Serializable {

    private static final long serialVersionUID = -4376306330901620128L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    //笔记博文标题
    @Column(nullable = false)
    private String noteTitle;
    //描述
    @Column(nullable = false) //变长
    @Lob
    @Basic(fetch = FetchType.LAZY)
    private String noteDescription;
    //内容

    @Lob
    @Column(nullable = false)
    @Basic(fetch = FetchType.LAZY)
    private String noteContent;

    @Column(nullable = false)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime noteCreateTime;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id",referencedColumnName = "id")
    @JsonIgnore
    private ChatUser user;
}
